<template>
	<view class = "gopay">
		<view class="ordernum">
			<text>订单编号:</text>
			<text>{{orderId}}</text>
		</view>
		<view class="ordernum">
			<text>订单金额:</text>
			<text>{{price}}</text>
		</view>
		<view class="payType">
			<text>选择支付方式:</text>
			<view class="content">
				<view class="pay-list">
					<view class="row" @tap="paytype='alipay'">
							<!-- <view class="left">
								<image src="/static/icons/alipay.png"></image>
							</view> -->
							<view class="center">
								支付宝支付
							</view>
							<view class="right">
								<radio :checked="paytype=='alipay'" color="#354E44" />
							</view>
					</view>
					<view class="row" @tap="paytype='wxpay'">
							<!-- <view class="left">
								<image src="/static/icons/wxpay.png"></image>
							</view> -->
							<view class="center">
								微信支付
							</view>
							<view class="right">
								<radio :checked="paytype=='wxpay'" color="#354E44" />
							</view>
					</view>
				</view>
			</view>
			<view class="payment" @tap="goPay">
				<button type="default">立即支付</button>
			</view>
		</view>
	</view>
</template>

<script>
	import http from "@/utils/http.js"
	export default {
		data() {
			return {
				userId:'',
				orderId:'',
				paytype:'alipay',//支付类型
				price:'',
			};
		},
		onLoad(e) {
			console.log(e);
			this.orderId = e.orderId;
			this.price = e.price;
			this.userId = JSON.parse(uni.getStorageSync("token")).id;
		},
		methods:{
			goPay() {
				uni.showLoading({
					title:"正在支付"
				})
				http.post("/api/leju/front/order/payConfirm",{
					orderId:this.orderId,
					userId:this.userId,
					payType:this.paytype
				}).then(res => {
					console.log(res,'支付页面');
					if(res.data.code == "S"){
						uni.showToast({
							title:'支付成功'
						})
						setTimeout(() => {
							uni.navigateTo({
								url:"/pages/kind/paySuccess/paySuccess?price="+this.price
							})
						},1000)
					}else{
						uni.showToast({
							title:'支付失败'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
